<template>
  <div class="home">
    <home-header/>
    <home-swiper :swiperUrl="swiperUrl"/>
    <home-icon :swiperList="swiperList"/>
    <home-posi/>
    <home-hot :list="list"/>
    <home-like :imgList="imgList"/>
    <home-detalis :numList="numList"/>
    <home-footer/>
  </div>
</template>
<script>
  import HomeHeader from './home_list/Header'
  import HomeSwiper from './home_list/Swiper'
  import HomeIcon from './home_list/List'
  import HomePosi from './home_list/Posi'
  import HomeHot from './home_list/Hot'
  import HomeLike from "./home_list/Like"
  import HomeDetalis from "./home_list/Detalis"
  import HomeFooter from "./home_list/Footer"
  import {mapState} from 'vuex'

  export default {
    data() {
      return {
        swiperUrl: [],
        swiperList: [],
        imgList: [],
        numList: [],
        list: [],
        changecity:""
      }
    },
    components: {
      HomeHeader,
      HomeSwiper,
      HomeIcon,
      HomePosi,
      HomeHot,
      HomeLike,
      HomeDetalis,
      HomeFooter
    },
    methods: {
      getdata() {
        this.$axios.get("http://yuanyuanyuan.xyz/qunaerw/yuan.php").then(require => {
          var data = require.data.data;

          data.forEach((item, index) => {
            if (item.city == this.city) {
              this.swiperUrl = item.swiperUrl;
              this.swiperList = item.swiperList;
              this.imgList = item.imgList;
              this.numList = item.numList;
              this.list = item.list;
            }
            console.log(item.city)
          })
        })
      }
    },
    mounted() {
      this.getdata()
      this.changecity=this.city
    },
    computed: {
      ...mapState(["city"])
    },
    activated(){
    if(this.changecity!=this.city){
      this.getdata()
      this.changecity=this.city
    }
    }
  }
</script>
<style>
  .home {
    background-color: #f5f5f5;
  }

</style>
